#import "BWActionButtonCell.h"

@implementation BWActionButtonCell

- (id) initTextCell: (NSString *) stringValue
          pullsDown: (BOOL) pullDown
{
    if (self = [super initTextCell: stringValue
                      pullsDown: pullDown]) {
        buttonCell = [[NSButtonCell alloc] init];
        [buttonCell setBordered: NO];
        [buttonCell setImagePosition: NSImageOnly];

        NSImage *normalImage, *alternateImage;
        normalImage = [NSImage imageNamed: @"action"];
        alternateImage = [NSImage imageNamed: @"action-highlight"];

        [buttonCell setImage: normalImage];
        [buttonCell setAlternateImage: alternateImage];
    }

    return (self);

} // initTextCell



- (void) dealloc
{
    [buttonCell release];

    [super dealloc];

} // dealloc



- (void) drawWithFrame: (NSRect) cellFrame 
                inView: (NSView *) controlView
{
    [buttonCell drawWithFrame: cellFrame  inView: controlView];

} // drawWithFrame



- (void) highlight: (BOOL) flag
         withFrame: (NSRect) cellFrame
            inView: (NSView *) controlView
{
    [super highlight: flag
           withFrame: cellFrame
           inView: controlView];

    [buttonCell highlight: flag
                withFrame: cellFrame
                inView: controlView];

} // highlight withFrame



- (void) setImage: (NSImage *) image
{
    [buttonCell setImage: image];

} // setImage



- (void) performClick: (id) sender
{
    [super performClick: sender];
    [buttonCell performClick: sender];

} // performClick

@end // BWActionButtonCell

